package br.diego.tb.advancedtechniques;

public class Coins {
	
	  public static int minimum_coins(Integer[] possibleCoins, Integer change) {
		  
		  int indexOfLastCoin = possibleCoins.length - 1;
		  
		  int totalCoins = 0;
		  
		  for(int i = indexOfLastCoin; i >= 0; i --)
		  {
			  int mod = change % possibleCoins[i];
			  
			  
			  if(mod < change)
			  {
				  totalCoins += (change/possibleCoins[i]);
				  change = mod;
			  }
			  
		  }
		  
		  if(change != 0)
		  {
			  
		  }
		  
		  System.out.println(totalCoins);
		  
		  return totalCoins;
	  
	  }
	  

}
